
package ProOF.apl.problems.real.operators;

import ProOF.apl.problems.real.RealCodification;
import ProOF.apl.problems.real.RealProblem;
import ProOF.gen.operator.oCrossover;
import ProOF.gen.operator.oInitializer;
import ProOF.utilities.uUtil;

/**
 *
 * @author Hossomi
 */
public class RealCrossAVG extends oCrossover<RealProblem, RealCodification> {

    @Override
    public String name() {
        return "Average";
    }

    @Override
    public RealCodification crossover(RealProblem prob, RealCodification ind1, RealCodification ind2) throws Exception {
        RealCodification child = ind1.New(prob);
        for (int i = 0; i < prob.func.dimension(); i++) {
            child.x[i] = (ind1.x[i] + ind2.x[i])/2;
        }
        prob.func.adjust(child.x);
        
        return child;
    }

}
